package demo_0402;

import java.util.Date;

public class Test {
//    日期类
    public static void main(String[] args) {
        java.util.Date now = new java.util.Date();
        System.out.println(now);
        Date birthday = new Date(10,1,1);
        System.out.println(birthday);
        System.out.println("year" + (now.getYear() + 1900));
        System.out.println("month" + (now.getMonth() + 1));
        System.out.println("day" + now.getDate());
        System.out.println("hour" + now.getHours());
        System.out.println("minute" + now.getMinutes());
    }
//    时间戳
    public static void main2(String[] args) {
        long start = System.currentTimeMillis();
        for (int i = 0; i < 10000; i++) {
            System.out.println(i);
        }
        long end = System.currentTimeMillis();
        System.out.println(end - start);
    }

//    字符串拼接
    public static void main1(String[] args) {
        String str = "Hello, World!";
        String name = "张三";
        int age = 20;
        String address = "梦溪路";

        StringBuilder sb = new StringBuilder();
        sb.append("名字是：").append(name).append(" 年龄是：").append(age).append(" 地址是：").append(address).append("。");
        System.out.println(sb);

        System.out.println(sb.length());
        System.out.println("capacity" + sb.capacity()); //分配的内存空间，单位是字符

        System.out.println("----------------------");

        String[] interests = {"游泳", "篮球", "足球", "乒乓球", "羽毛球", "网球"};
        StringBuilder sb1 = new StringBuilder();
        for (String interest : interests) {
            sb1.append(interest).append(",");
        }
        System.out.println("兴趣是" + sb1);
    }
}
